//============================================================================
// Name        : stdGNUTDefs.h
// Author      : Jonathan Ellithorpe and Allen Lee
// Version     :
// Copyright   : UC Berkeley
// Description : Standard GNUT Parameter Definitions
//============================================================================

#ifndef STDGNUTDEFS_H_
#define STDGNUTDEFS_H_

// NEIL!!! (Warren, that is)
#ifndef NULL
#define NULL 0
#endif

// to make closing sockest more clear
#define closesocket close

// Use MNL boolean to switch on/off the use of MNL
//#define USEMNL

const int OneMillion = 1000000;

const int AdvertisedWindow = (1 << 11) - 1;

// chunk size to send to ClientConnection send method from file
const unsigned int FileChunkSize = (1 << 19);

// for debugging output
const bool verbose = true; // set as a command line argument

// Maximum segment size (refers to payload only (not header))
const unsigned short MSS = 7;

// Maximum wait between retries
const unsigned int MaxWait = 16000000;

// Port Scanning
const unsigned int NumPortsToTry = 100;

// Start port for port scanning
const unsigned short StartPort = 4500;

// Constants for RTO computation
const double Alpha = 7.0/8.0;
const double Delta = 1.0/4.0;
const double Mu = 1.0;
const double Phi = 4.0;

// Maximum number of retries
const unsigned short MaxTimeouts = 16;

enum {
	SYN = 1,
	ACK = 2,
	RST = 3,
	FIN = 4,
	DAT = 5
};

typedef struct GNUT_Header {
	unsigned short srcPort;
	unsigned short dstPort;
	unsigned int SeqAckNo;
	unsigned int AdvWindow;
	unsigned short TypeSize;
	unsigned short CheckSum;
} GNUT_Header_t;

typedef struct GNUT_Packet {
	GNUT_Header_t header;
	char* payload;
	unsigned int payloadLen;
} GNUT_Packet_t;

typedef struct GNUT_dataBlock {
	unsigned int SeqNo;
	unsigned int size;
	char* dataPtr;
	struct GNUT_dataBlock* next;
	struct GNUT_dataBlock* prev;
} GNUT_dataBlock_t;

#endif /*STDGNUTDEFS_H_*/
